<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
$return['ischecklogin']=cfc('core')->checklogin('','',true);
if($_RQ['op']=='get'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	$return['member']=$member;
	if(!model('core/member/cash')->check_open() || $member['notixian']){
		$return['notixian']=1;
	}
	$setting=uni_setting('register');
	$iscode=$setting['dxmb'] && $setting['login_type']?1:0;
	$return['params']['type']=$_RQ['type']?:2;
	$return['post']['iscode']=$iscode;
	$pay=uni_setting('pay');
	$return['iszhuan']=$pay['credit2_zhuan'];
	set_html('title','我的余额');
	exi($return);
}
if($_RQ['op']=='post'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	$post=get_postdata();
	if(!$post['fee']){
		exi('请输入转账金额！','erroe');
	}
	if(!$post['mobile']){
		exi('请输入收款人账户/手机号！','erroe');
	}
	if(!$post['password'] && $post['needpassword']){
		exi('请输入支付密码！','erroe');
	}
	if((!$post['password'] || $post['password']!=$member['paypassword']) && $post['needpassword']){
		exi('支付密码不正确！','erroe');
	}
	if($member['credit2']<$post['fee']){
		exi('转账额度不能大于，当前余额！','erroe');
	}
	if($post['mobile']==$member['mobile']){
		exi('不能给自己转账！','erroe');
	}
	$tomember=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'username'=>$post['mobile']));
	$tomid=$tomember['id'];
	if(!$tomid){
		$tomember=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'mobile'=>$post['mobile']));
		$tomid=$tomember['onemid']?:$tomember['id'];
	}
	if(!$tomid){
		exi('没找到收款人，转账失败！','erroe');
	}
	model('core/member')->cut_credit2($_SESSION['uid'],$post['fee'],'转账给:'.$post['mobile']);
	model('core/member')->add_credit2($tomid,$post['fee'],$member['username'].'的转账');
	exi('转账成功！');
}
if($_RQ['op']=='password'){
	$post=get_postdata();
	if(!$post['password']){
		exi('请输入支付密码！','erroe');
	}
	if($post['iscode'] && !check_sms_code($post['smscode'])){
		exi('手机验证码错误！不能修改密码！','error');
	}
	pdo_update('core_members',array('paypassword'=>$post['password']),array('id'=>$_SESSION['uid']));
	exi('设置成功！');
}